<?php
/**
* Bysoft
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com and you will be sent a copy immediately.
*
* @category   Bysoft
* @package    Bysoft_Flashnavigator
* @author     Bysoft
* @copyright  Copyright (c) 2009 Bysoft (http://www.bysoft.fr)
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/ 

class Bysoft_Flashnavigator_Block_Adminhtml_Flashnavigator_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
    public function __construct()
    {
        parent::__construct();

        $this->_objectId = 'id';
        $this->_blockGroup = 'flashnavigator';
        $this->_controller = 'adminhtml_flashnavigator';

        $this->_updateButton('save', 'label', Mage::helper('flashnavigator')->__('Save Item'));
        //$this->_updateButton('delete', 'label', Mage::helper('flashnavigator')->__('Delete Item'));

        /*$this->_addButton('saveandcontinue', array(
            'label'     => Mage::helper('adminhtml')->__('Save And Continue Edit'),
            'onclick'   => 'saveAndContinueEdit()',
            'class'     => 'save',
        ), -100);*/

        $this->_formScripts[] = "
            function toggleEditor() {
                if (tinyMCE.getInstanceById('flashnavigator_content') == null) {
                    tinyMCE.execCommand('mceAddControl', false, 'flashnavigator_content');
                } else {
                    tinyMCE.execCommand('mceRemoveControl', false, 'flashnavigator_content');
                }
            }

            function saveAndContinueEdit(){
                editForm.submit($('edit_form').action+'back/edit/');
            }
        ";
    }

    public function getHeaderText()
    {
        if( Mage::registry('flashnavigator_data') && Mage::registry('flashnavigator_data')->getId() ) {
            return Mage::helper('flashnavigator')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('flashnavigator_data')->getTitle()));
        } else {
            return Mage::helper('flashnavigator')->__('Item Manager');
        }
    }
}